package com.ruoyi.system.controller;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.req.DataTableReq;
import com.ruoyi.system.domain.req.ProcessData;
import com.ruoyi.system.domain.vo.DataTableVo;
import com.ruoyi.system.service.IDatabaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/dataTable")
public class DataTableController extends BaseController {

    @Autowired
    private IDatabaleService databaleService;
    /**
     * 展示数据
     */
    @GetMapping("/getDataTableList")
    public AjaxResult list(DataTableReq dataTableReq)
    {
        DataTableVo data = databaleService.selectDataTableList(dataTableReq);
        return AjaxResult.success(data);
    }

    /**
     * 生成数据
     */
    @PostMapping("/generateData")
    public AjaxResult generateData(@RequestBody DataTableReq dataTableReq) throws InterruptedException {
        DataTableVo dataTableVo = databaleService.generateData(dataTableReq);
        return AjaxResult.success(dataTableVo);
    }

    /**
     * 获取数据进度
     */
    @GetMapping("/getProgress")
    public AjaxResult getProgress(DataTableReq dataTableReq)
    {
        return AjaxResult.success(databaleService.getProgress(dataTableReq));
    }

    /**
     * 发送数据进度
     */
    /**
     * 生成数据
     */
    @PostMapping("/sendData")
    public AjaxResult sendData(@RequestBody DataTableReq dataTableReq) throws InterruptedException {
        DataTableVo dataTableVo = databaleService.sendData(dataTableReq);
        return AjaxResult.success(dataTableVo);
    }

    /**
     * 获取数据进度
     */
    @GetMapping("/getSendProgress")
    public AjaxResult sendProgress(DataTableReq dataTableReq)
    {
        return AjaxResult.success(databaleService.sendProgress(dataTableReq));
    }

}
